Ext.namespace('Ext.ux','Vector','Vector.VectorManager','Vector.SVG','Vector.VML','Vector.Graph');

Vector.PathToBaseScripts = 'Vector/';
/**
 * @class Vector.VectorManager
 * This class is a singleton that manages vector objects 
 */
Vector.VectorManager = function(){
	var vectorType = 'vml';  //vml or svg
	return{
	/**
	 * Sets up required vector graphics options per browser
	 */
		setupVector: function(){
			var baseHtml = document.getElementsByTagName('html')[0];
			var baseHead = document.getElementsByTagName('head')[0];
			var htmlNS = '';
			var htmlNSText = '';
			var vectorBase = '';
			if(Ext.isIE||Ext.isIE7){
				vectorBase = 'BaseVml.js';
				Vector.Loader.load(Vector.PathToBaseScripts + vectorBase,this.setupVectorClass, this, ['vml']);
				
				htmlNS = 'xmlns:v';
				htmlNSText = 'urn:schemas-microsoft-com:vml';
				var cssStr = 'v\\:* { behavior: url(#default#VML); display:inline-block }';
				var style = document.createElement("style");
				style.setAttribute("type", "text/css");
				style.styleSheet.cssText = cssStr;
				baseHead.appendChild(style);

			}else{
				vectorBase = 'BaseSVG.js';
				
				Vector.Loader.load(Vector.PathToBaseScripts + vectorBase,this.setupVectorClass, this, ['svg']);
				htmlNS = 'xmlns';
				htmlnstext = 'http://www.w3.org/1999/xhtml';
				
				var meta=document.createElement("meta");
			    meta.setAttribute("http-equiv","Content-Type");
			    meta.setAttribute("content","application/xhtml+xml");
			    baseHead.appendChild(meta);
				
				baseHtml.setAttribute("xmlns","http://www.w3.org/1999/xhtml");
				baseHtml.setAttribute("xmlns:svg","http://www.w3.org/2000/svg");
				baseHtml.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
			}
		},
		setupVectorClass: function(vt){
			if(vt=='vml'){
				vectorType = Vector.VML;
			}else{
				vectorType = Vector.SVG;
			}
		},
		/**
		 * Factory method for returning a basic line object
		 * @param {Object} config
		 */
		getLine: function(config){
			return new vectorType.Line(config);
		},
		/**
		 * Returns a polyline
		 * @param {Object} config
		 */
		getPoly: function(config){
			return new vectorType.Polyline(config);
		},
		/**
		 * 
		 * @param {Object} config
		 */
		getBox: function(config){
			return new vectorType.Box(config);
		},
		/**
		 * 
		 * @param {Object} config
		 */
		getGroup: function(config){
			return new vectorType.Group(config);
		},
		/**
		 * 
		 * @param {Object} config
		 */
		getCanvas: function(config){
			return new vectorType.Canvas(config);
		},
		/**
		 * 
		 * @param {Object} config
		 */
		getRoundBox: function(config){
			return new vectorType.RoundBox(config);
		},
		/**
		 * 
		 * @param {Object} config
		 */
		getImage: function(config){
			return new vectorType.Image(config);
		}
	}
}();
Ext.onReady(Vector.VectorManager.setupVector, Vector.VectorManager, true);